/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.swosh.stomp.ejb;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;

/**
 *
 * @author swosh
 */
@Entity
public class Person implements Serializable {

    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Id
    private int id;
    @Column(nullable = false)
    private String name;
    
    private String description;
    @Lob
    @Basic(fetch = FetchType.EAGER)
    private byte[] image;
    private String municipalty;
    @Column(nullable = false)
    private String street;
    private int numOri;
    private double lat = 0;
    private double lon = 0;

    public Person() {
    }

    /**
     * Konstruktor pro Person s obrázkem
     * @param name
     * @param description
     * @param image
     * @param municipalty
     * @param street
     * @param numOri
     */
    public Person(String name, String description, byte[] image, String municipalty, String street, int numOri) {
        this.name = name;
        this.description = description;
        this.image = image;
        this.municipalty = municipalty;
        this.street = street;
        this.numOri = numOri;
    }

    /**
     * Konstruktor pro Person bez obrázku. Nejpoužitelnější
     * @param name
     * @param description
     * @param municipalty
     * @param street
     * @param numOri
     */
    public Person(String name, String description, String municipalty, String street, int numOri) {
        this.name = name;
        this.description = description;
        this.municipalty = municipalty;
        this.street = street;
        this.numOri = numOri;
    }

    public Person(int id, String name, String description, byte[] image, String municipalty, String street, int numOri, double  lat, double  lon) {

        this.id = id;
        this.name = name;
        this.description = description;
        this.image = image;
        this.municipalty = municipalty;
        this.street = street;
        this.numOri = numOri;
        this.lat = lat;
        this.lon = lon;
    }

    /**
     * Poskytuje ID pro Person entitu. Pro autogenerování sequence do databáze
     * Postgres je nejsnažsí užití GenerationType.IDENTITY v @GeneratedValue.
     * Pro použití kódu níže je třeba mít už v db sequenci. Záleží prý
     * na nastavení databáze. Každá se chová jinak. Doporučuje se GenerationType.AUTO.
     * Mě v Postgre neudělá sequenci, ale tabulku.
     * 
     *     @SequenceGenerator(name = "person_seq", sequenceName="person_seq", initialValue=1,allocationSize=Integer.MAX_VALUE)
     *     @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="person_seq")
     * @return
     */
    
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public byte[] getImage() {
        return image;
    }

    public void setImage(byte[] image) {
        this.image = image;
    }

    public String getMunicipalty() {
        return municipalty;
    }

    public void setMunicipalty(String municipalty) {
        this.municipalty = municipalty;
    }

    public String getStreet() {
        return street;
    }

    public void setStreet(String street) {
        this.street = street;
    }

    public int getNumOri() {
        return numOri;
    }

    public void setNumOri(int numOri) {
        this.numOri = numOri;
    }

    public double getLat() {
        return lat;
    }

    public void setLat(double lat) {
        this.lat = lat;
    }

    public double getLon() {
        return lon;
    }

    public void setLon(double lon) {
        this.lon = lon;
    }
}
